better code for loader logic