Added if-statements and counter