Solution for the assignment, version 1