initial commit with a little optimisation