cleaned up image handling