Moved code where it belongs