some optimisations and stuffs