Logic now working