Added break when function returns something invalid