changed some exits to returns