Amber when running
Refactor to simplify code