Cleaned up img code