An attempt to improve performance - use only one stack