Almost finished, left test unit to be written