refactored a bit + adding some test