Added variable result and if statement

Added variable result and if statement