Reworked
Added tests