Working correctly

Program works correctly now