functions and ifelse statments solved