tried to simplify it a bit