simplified and optimised crop js