Moved function to limit errors