Removed int casting, used long type
int casting doesnt work as expected