had to use if-statements to prevents errors; but working