made conditions more readable and added check for size in memory. Prepared for (bool, error) return parameter for details why.