Moved some logic