refactoring

removed unneccessary check on number of elements.
made the code a bit clearer