implemented if/else block and stack handling correctly. added more tests