code repetition removed