Moved code entirely to main module and it is working.