Fixed the problem but image loading is slow (added semaphore)