Added comments, unit tested