image code refactored, added amap init at image