Fix bug with if/elif; add return values to functions