Added functions and fixed automation