Finished version, just need to check extreme cases...