file handles and other functions